<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
 * FormativeLab
 *
 * An open source application development framework for PHP 5.1.6 or newer
 *
 * @package		FormativeLab
 * @author		FormativeLab Dev Team
 * @copyright	Copyright (c) 2011 - 2013, FormativeLab, Inc.
 * @license		http://www.formativesoft.com/license/
 * @link		http://www.formativesoft.com/
 * @since		Version 2.0
 * @filesource ./application/helpers/model_helper.php
 */

// ------------------------------------------------------------------------

/**
 * FormativeLab Resource Helpers
 *
 * @package		FormativeLab
 * @subpackage	Helpers
 * @category	Helpers
 * @author		Formative Soft Ltd
 * @link		http://www.formativesoft.com/
 */

// ------------------------------------------------------------------------

/**
 * scriptTag() Takes four input parameter return a string, First parameter
 * is mandatory and rest of three parameters are optional
 *
 * scriptTag usefull for generate dynamic java script tag specially for
 * view pages
 *
 * @access	public
 * @param	src
 * @param	language
 * @param	type
 * @param   indexPage
 * @return	string
 */
if (!function_exists('scriptTag')) {
    function scriptTag($src, $language = 'javascript', $type = 'text/javascript', $indexPage = FALSE){
        $CI =& get_instance();
        $script = '<script';
		
		if ( strpos($src, '://') !== FALSE) {
			$script .= ' src="'.$src.'" ';
		}else if ($indexPage === TRUE) {
			$script .= ' src="'.$CI->config->base_url($src).'" ';
		}else {
			$script .= ' src="'.$CI->config->slash_item('base_url').$src.'" ';
		}
		//$script .= 'language="'.$language.'" type="'.$type.'"';
		$script .= 'type="'.$type.'"';
		$script .= ' ></script>'."\n";
		
        return $script;
    }
}

// ------------------------------------------------------------------------

/**
 * styleTag() Takes four input parameter return a string, First parameter
 * is mandatory and rest of three parameters are optional
 *
 * styleTag usefull for generate dynamic style sheet tag specially for
 * view page
 *
 * @access	public
 * @param	href
 * @param	rel
 * @param	type
 * @param	indexPage
 * @return	string
 */
if (!function_exists('styleTag')) {
    function styleTag($href, $rel='stylesheet', $type = 'text/css', $indexPage = FALSE){
        $CI =& get_instance();
        $link = '<link';

		if ( strpos($href, '://') !== FALSE) {
			$link .= ' href="'.$href.'" ';
		}else if ($indexPage === TRUE) {
			$link .= ' href="'.$CI->config->base_url($href).'" ';
		}else {
			$link .= ' href="'.$CI->config->slash_item('base_url').$href.'" ';
		}
		$link .= 'rel="'.$rel.'" type="'.$type.'"';
		$link .= ' ></link>'."\n";
        
        return $link;
    }
}

// ------------------------------------------------------------------------

/**
 * faviconTag() Takes four input parameter return a string, First parameter
 * is mandatory and rest of three parameters are optional
 *
 * faviconTag usefull for generate dynamic favicon link tag specially for
 * view page
 *
 * @access	public
 * @param	href
 * @param	rel
 * @param	type
 * @param	indexPage
 * @return	string
 */
if (!function_exists('faviconTag')) {
    function faviconTag($href, $rel='shortcut icon', $type = 'image/x-icon', $indexPage = FALSE){
        $CI =& get_instance();
        $link = '<link';
		
		if ( strpos($href, '://') !== FALSE) {
			$link .= ' href="'.$href.'" ';
		}else if ($indexPage === TRUE) {
			$link .= ' href="'.$CI->config->base_url($href).'" ';
		}else {
			$link .= ' href="'.$CI->config->slash_item('base_url').$href.'" ';
		}
		$link .= 'rel="'.$rel.'" type="'.$type.'"';
		//$link .= ' ></link>'."\n";
		$link .= ' />'."\n";
      
        return $link;
    }
}

// ------------------------------------------------------------------------

/**
 * appFolderPath() Takes two input parameter return a string, First parameter
 * is mandatory and rest of single parameter is optional
 *
 * appFolderPath usefull for get appFolder of Extjs 4.1 Client Side MVC with
 * Extjs 4.1 Data Package
 *
 * @access	public
 * @param	appFolder
 * @param	indexPage
 * @return	string
 */
if (!function_exists('appFolderPath')) {
    function appFolderPath($appFolder, $indexPage = FALSE){
        $CI =& get_instance();
        $appFolderPath ;

		if ( strpos($appFolder, '://') !== FALSE) {
			$appFolderPath = $appFolder;
		}else if ($indexPage === TRUE) {
			$appFolderPath = $CI->config->base_url($appFolder);
		}else {
			$appFolderPath = $CI->config->slash_item('base_url').$appFolder.'" ';
		}        
        return $appFolderPath;
    }
}

// ------------------------------------------------------------------------

/**
 * isInternetExplorer() to check the user agent is Internet Explorer. For ensuring
 * compartibility environment for that
 *
 * @access	public
 * @return	bool
 */
if (!function_exists('isInternetExplorer')) {
    function isInternetExplorer(){
        $CI =& get_instance();
		return $CI->agent->browser() == 'Internet Explorer';
    }
}


/* End of file model_helper.php */
/* Location: ./application/helpers/model_helper.php */